<template>
  <el-dialog
    :visible.sync="dialogVisible"
    :width="dialogType === 1 ? '20%' : '60%'"
    :title="dialogType === 1 ? '上链' : '参数接口'"
    :before-close="closeDialog"
    custom-class="custom-dialog"
  >
    <span v-if="dialogType === 1">您确定要上链吗？</span>
    <div class="flex justify-center" v-if="dialogType === 2">
      <div class="json_wrapper">
        <h5>入参接口</h5>
        <pre>{{ requestInfo }}</pre>
      </div>
      <div class="json_wrapper">
        <h5>返回接口</h5>
        <pre>{{ responseInfo }}</pre>
      </div>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button v-if="dialogType === 1" @click="closeDialog">取 消</el-button>
      <el-button type="primary" @click="closeDialog">{{
        dialogType === 1 ? "确 定" : "关 闭"
      }}</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  props: {
    dialogVisible: {
      type: Boolean,
      default: false,
    },
    dialogType: {
      type: Number,
    },
    requestInfo: {
      type: Object,
      default: () => ({}),
    },
    responseInfo: {
      type: Object,
      default: () => ({}),
    },
  },
  methods: {
    closeDialog(param) {
      this.$emit("close", param);
    },
  }
};
</script>

<style lang="scss" scoped>
.custom-dialog {
  .el-dialog__header {
    background: #f5f5f5;
    box-shadow: 0px 1px 0px 0px #eeeeee;
  }
  .el-dialog__footer {
    text-align: center;
  }
}
</style>